package com.albert;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeTest2 {
    public static void main(String[] args) {
        String time1 = "2024-10-28T01:18:49.2430114Z";
        String time2 = "2024-10-16T06:39:31Z";
        String time3 = "2024-10-24T02:52:44.841003Z";
        String time = getTime(time1);
        System.out.println(time1.length());
        System.out.println(time);


    }
    public static String getTime(String inputTime){
        SimpleDateFormat inputFormat = null;
        if(inputTime.length()==20){
            inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        } else {
            inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
        }
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = null;
        System.out.println("2024-10-16T06:39:31Z".length());
        try {
            Date date1 = inputFormat.parse(inputTime);
            format = outputFormat.format(date1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return format;
    }
}
